//
//  LzwBnimaLoadingCell.m
//  CoJellyCartoon
//
//  Created by 刘志武 on 16/4/1.
//  Copyright © 2016年 CJG. All rights reserved.
//

#import "LzwBnimaLoadingCell.h"

#import "LzwBniTopCollectCell.h"


@interface LzwBnimaLoadingCell ()<UICollectionViewDataSource, UICollectionViewDelegate>

@property (nonatomic, strong) UIImageView *myImageView;
@property (nonatomic, strong) UILabel *labbelTitle;

@property (nonatomic, strong) UICollectionView *myCollectView;

@end


@implementation LzwBnimaLoadingCell


-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    
    if (self) {
        [self creatS];
    }
    
    return self;
}


- (void)creatS{
    
    
    self.myImageView = [[UIImageView alloc]initWithFrame:CGRectMake(15, 5, 30, 30)];
    self.myImageView.backgroundColor = [UIColor yellowColor];
    self.myImageView.layer.masksToBounds = YES;
    self.myImageView.layer.cornerRadius = 15;
    self.myImageView.image = [UIImage imageNamed:@"L3.png"];
    [self.contentView addSubview:self.myImageView];
    
    self.labbelTitle = [[UILabel alloc]initWithFrame:CGRectMake(50, 10, 200, 20)];
    self.labbelTitle.text = @"新番连载";
    self.labbelTitle.textColor = [UIColor lightGrayColor];
    self.labbelTitle.font = [UIFont systemFontOfSize:15];
    [self.contentView addSubview:self.labbelTitle];
    
    self.myCollectView = ({
    
        UICollectionViewFlowLayout *myLayOut = [[UICollectionViewFlowLayout alloc]init];
        
        myLayOut.itemSize = CGSizeMake(175, 150);
        
        myLayOut.sectionInset = UIEdgeInsetsMake(15, 10, 5, 10);
        
        myLayOut.minimumInteritemSpacing = 5;
        myLayOut.minimumLineSpacing = 10;

        UICollectionView *myCollectView = [[UICollectionView alloc]initWithFrame:CGRectMake(0, 40, SCREEN_WIDTH, 650) collectionViewLayout:myLayOut];
    
        myCollectView.scrollEnabled = NO;
        myCollectView.scrollsToTop = YES;
        myCollectView.delegate = self;
        myCollectView.dataSource = self;
        
        myCollectView.backgroundColor = [UIColor whiteColor];
        
        [self.contentView addSubview:myCollectView];
        
        myCollectView;
    
    
    });
    
    [self.myCollectView registerClass:[LzwBniTopCollectCell class] forCellWithReuseIdentifier:@"cell"];

}

-(NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section{
    
    return self.arrayAll.count;
}

- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath{
    
    LzwBniTopCollectCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"cell" forIndexPath:indexPath];
    
    cell.modleLates = self.arrayAll[indexPath.row];
    
    return cell;
}

-(void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath{
    
    LzwLatesModel *modele = _arrayAll[indexPath.row];
    
//    [self.myDeleGate bnimalLoadingCellAction:modele.season_id.intValue];

    [self.myDeleGate bnimalLoadingCellAction:modele.season_id.intValue oldID:modele.newest_ep_id.intValue];
    
//    [self.myDeleGate bnimalLoadPLcell:modele.newest_ep_id.intValue];
    
    
}

-(void)setArrayAll:(NSMutableArray<LzwLatesModel *> *)arrayAll{
    
    _arrayAll = arrayAll;
    
    [self.myCollectView reloadData];
}


@end
